package guda.stark.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.stark.dal.dao.SysVarDAO;
import guda.stark.dal.dataobject.SysVarDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SysVarDAOImpl extends BaseDAO implements SysVarDAO {

    @Override
	public Long insert(SysVarDO sysVar) {
	      try {
                return (Long) getSqlMapperW().insert("sys_var.insert",sysVar);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public SysVarDO getSysVarById(Long varId) {
	    return (SysVarDO)getSqlMapClientTemplate().queryForObject("sys_var.getSysVarById", varId);
	}

    @Override
	public boolean delSysVarById(Long varId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("sys_var.delSysVarById",varId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<SysVarDO> getSysVarByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("sys_var.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long varId) {
	    try {
            getSqlMapperW().update("sys_var.cleanAutoIncrement",varId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<SysVarDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("sys_var.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("sys_var.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(SysVarDO sysVar) {
        try {
            getSqlMapperW().update("sys_var.updateByIdSelective",sysVar);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

